package com.example.net_library.net

import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

private val client by lazy {
     OkHttpClient.Builder()
         .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
         .addInterceptor {
             val request = it.request().newBuilder().addHeader(
                 "token",
                 "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJjaGVuIn0.j5851TiKVIscNv02err5UYPkSZkWmfkFhONmO-Gv6uc"
             ).build()
             it.proceed(request)
         }
         .build()
 }
val retrofit: Retrofit by lazy {
    Retrofit.Builder()
        .client(client)
        .baseUrl("http://10.161.9.80:7015/")
        .addConverterFactory(GsonConverterFactory.create())
        .build()
}
inline fun <reified T> service():T = retrofit.create(T::class.java)